{extend name='table'}

{block name="button"}
<!--{if auth('user.rebate.config/index')}-->
<a data-table-id="ReabteRecordTable" class="layui-btn layui-btn-sm layui-btn-primary" data-width="1024px" data-modal="{:url('user.rebate.config/index')}">{:lang('返佣配置')}</a>
<!--{/if}-->
{/block}

{block name="content"}
<div class="think-box-notify sub-strong-blue" type="info">
    <strong>{:lang('返佣统计')}：</strong>{:lang('累计已产生返佣')} <b>{$rebate.0+$rebate.2}</b> {:lang('元')} ( {:lang('含未到账')} <b>{$rebate.2|default='0.00'}</b> {:lang('元')} )，{:lang('累计已提现')} <b>{$total.1|default=0.00}</b> {:lang('元')}。
</div>
<div class="think-box-shadow">
    {include file='user/rebate/index_search'}
    <table id="ReabteRecordTable" data-line="2" data-url="{:request()->url()}" data-target-search="form.form-search"></table>
</div>

<script>
    $(function () {
        let ostatus = ['{:lang("未到账")}', '{:lang("已到账")}'];
        let ostyles = ['layui-bg-blue', 'layui-bg-green'];

        $('#ReabteRecordTable').layTable({
            even: true, height: 'full',
            sort: {field: 'id', type: 'desc'},
            cols: [[
                {field: 'id', hide: true},
                {fixed: true, checkbox: true},
                {
                    title: '{:lang("代理头像")}', width: 80, align: 'center', templet: function (d) {
                        if (!d.user || !d.user.headimg) return '';
                        return laytpl('<div>{{-showTableImage(d.user.headimg,true,"sm")}}</div>').render(d)
                    }
                },
                {
                    title: '{:lang("代理账号")}', templet: function (d) {
                        let tpls = [];
                        tpls.push('{:lang("账号昵称")}：<b>{{d.user.nickname}}</b>')
                        tpls.push('{:lang("账号手机")}：<b class="color-blue">{{d.user.phone}}</b>')
                        return laytpl(tpls.join('<br>')).render(d);
                    }
                },
                {
                    title: '{:lang("返佣信息")}', templet: function (d) {
                        let tpls = [];
                        tpls.push('{:lang("返佣金额")}：<b class="color-text">{{Number(d.amount)}}</b> {:lang("元")}，<span class="color-desc font-s12">' + '{:lang("第")}' + ' {{d.layer+1}} {:lang("笔")}</span>')
                        tpls.push('{:lang("返佣名称")}：{{d.name||"-"}}')
                        // tpls.push('{:lang("返佣单号")}：{{d.code||"-"}}')
                        let refund = laytpl('<span class="layui-badge layui-badge-middle flex-center {{d.style}}" style="zoom:85%;line-height:15px;padding:3px 4px">{{d.status}}</span>').render({
                            status: ostatus[d.status], style: ostyles[d.status]
                        });
                        return laytpl('<div class="flex">' + refund + '<div class="nowrap sub-strong-blue">' + tpls.join('<br>') + '</div></div>').render(d);
                    }
                },
                {
                    title: '{:lang("用户头像")}', width: 80, align: 'center', templet: function (d) {
                        if (!d.ouser || !d.ouser.headimg) return '<div class="ta-pt-10">-</div>';
                        return laytpl('<div>{{-showTableImage(d.ouser.headimg,true,"sm")}}</div>').render(d)
                    }
                },
                {
                    title: '{:lang("用户账号")}', templet: function (d) {
                        if (!d.ouser || !d.ouser.headimg) return '<div class="ta-pt-10">-</div>';
                        let tpls = [];
                        tpls.push('{:lang("账号昵称")}：<b>{{d.ouser.nickname}}</b>')
                        tpls.push('{:lang("账号手机")}：<b class="color-blue">{{d.ouser.phone}}</b>')
                        return laytpl(tpls.join('<br>')).render(d);
                    }
                },
                {
                    title: '{:lang("订单信息")}', templet: function (d) {
                        let tpls = [];
                        tpls.push('{:lang("支付金额")}：<b class="color-text">{{Number(d.order_amount)}}</b> {:lang("元")}')
                        tpls.push('{:lang("订单单号")}：{{d.order_no||"-"}}')
                        return laytpl(tpls.join('<br>')).render(d);
                    }
                },
                {
                    title: '{:lang("返佣时间")}', templet: function (d) {
                        let tpls = [];
                        tpls.push('{:lang("返佣类型")}：{{d.type_name||"-"}}')
                        tpls.push('{:lang("返佣时间")}：{{d.create_time}}')
                        return laytpl(tpls.join('<br>')).render(d);
                    }
                },
            ]]
        });
    });
</script>
{/block}
